<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 	 <%@ include file="/common/import.jsp"%>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	
	<script type="text/javascript">
	$(function(){
		var memberId = "${param.memberId}";
		$.ajax({ 
			type:'post',
			url:"/member/memberTemp/memberTempView.action?memberId=" + memberId,
			dataType:'json',
			success:function(data){
				var member = data.member;
				$("#memberEname").html(member.memberEname);
				$("#memberCname").html(member.memberCname);
				$("#shortName").html(member.shortName);
				if(member.memberType == '20'){
					$("#memberType").html("个人");
				}else if(member.memberType == '21') {
					if(member.orgType == '0'){
						$("#memberType").html("机构(金融机构)");
					}else if(member.orgType == '1'){
						$("#memberType").html("机构(一般企业)");
					}else{
						$("#memberType").html("");
					}
				}
				$("#memberRoles").html(member.memberRoles);
				$("#mobile").html(member.mobile);
				$("#phone").html(member.phone);
				$("#email").html(member.email);
				clientManager(member.clientManager);
				//$("#clientManager").html();
				if(member.memberType == "20"){
					loadCert('personCertType',member.certType);
				}else if(member.memberType == "21"){
					loadCert('orgCertType',member.certType);
				}else{
					
				}
				$("#certNo").html(member.certNo);
			},
			error:function(){
				 alert("请检查服务器！");
			}
		}); 
	});
	//根据会员类型，加载证件类型
	function loadCert(memberType,typeValue){
		var memberRoles_url = "${ctx}/member/uct/queryMemberRoles.action?cateName=" + memberType;
		$.ajax({ 
			type:'post',
			url:memberRoles_url,
			dataType:'json',
			success:function(data){
				$("#certType").html("");
				for ( var i = 0; i < data.length; i++) {
					var textAndValue = data[i].split("|");
					var itemValue = textAndValue[0];
					var itemText = textAndValue[1];
					if(itemValue == typeValue){
						$("#certType").html(itemText);
					}else{

					}
	      		};			
			},
			error:function(){
				 alert("请检查服务器！");
			}
		}); 
	}
	
	function clientManager(key){
		var user_list_url = "${ctx}/member/uct/queryUsersByUType?userType=1";
		//alert(user_list_url);
		$.ajax({ 
			type:'post',
			url:user_list_url,
			dataType:'json',
			success:function(data){
				var users = data;
				for ( var i = 0; i < data.length; i++) {
					var user = users[i];				
					var username = user.userEname;
					var realname = user.userCname;
					if(username == key){
				   	 	$("#"+"clientManager").html(realname);
					}
	      		}			
			},
			error:function(){
				 alert("请检查服务器！");
			}
		});
	}
	</script>
  </head>
  <body>
		<div class="form-group" style="text-align: center;">
			<table id="userRegTable" align="center" border="1px red solid">
				<tr class="alt">
					<td>
						<label for="memberEname" class="col-sm-2 control-label">会员账号</label>
					</td>
					<td id="memberEname">
					</td>
				</tr>
				<tr>
					<td>
						<label for="memberCname" class="col-sm-2 control-label">会员全称</label>
					</td>
					<td id="memberCname">
					</td>
				</tr>
				<tr class="alt">
					<td>
						<label for="shortName" class="col-sm-2 control-label">会员简称</label>
					</td>
					<td id="shortName">
					</td>
				</tr>
				<tr class="alt">
					<td>
						<label for="memberType" class="col-sm-2 control-label">会员属性</label>
					</td>
					<td id="memberType">
						
					</td>
				</tr>
				<tr>
					<td>
						<label for="memberRoles" class="col-sm-2 control-label">会员类型</label>
					</td>
					<td id="memberRoles">
						
					</td>
				</tr>
				<tr class="alt">
					<td>
						<label for="mobile" class="col-sm-2 control-label">移动电话</label>
					</td>
					<td id="mobile">
					</td>
				</tr>
				<tr>
					<td>
						<label for="phone" class="col-sm-2 control-label">固定电话</label>
					</td>
					<td id="phone">
					</td>
				</tr>
				<tr class="alt">
					<td>
						<label for="email" class="col-sm-2 control-label">邮箱</label>
					</td>
					<td id="email">
					</td>
				</tr>
				<tr>
					<td>
						<label for="clientManager" class="col-sm-2 control-label">客户经理</label>
					</td>
					<td id="clientManager">
					</td>
				</tr>
				<tr class="alt">
					<td>
						<label for="certType" class="col-sm-2 control-label">证件类型</label>
					</td>
					<td id="certType">
					</td>
				</tr>
				<tr>
					<td>
						<label for="certNo" class="col-sm-2 control-label">证件号码</label>
					</td>
					<td id="certNo">
					</td>
				</tr>
			</table>
	</div>			
  </body>
</html>
